import roslibpy

class SetGait:

    def __init__(self, framework):
        self.framework = framework
        self.talker = None
        self.gait = 0

    def set(self, gait):
        if self.framework.framework.utils.device.device_state:
            self.gait = gait
            self.talker = roslibpy.Topic(self.framework.framework.utils.device.device_connect, "/alphadog_node/set_gait", "ros_alphadog/SetGait")
            self.talker.publish(roslibpy.Message({"gait": self.gait}))
            self.end()

    def end(self):
        self.gait = 0
